home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.mactech.com 2010
/
ftp.mactech.com.tar
/
ftp.mactech.com
/
macintosh-c
/
macc-carbon-demos-nonbinhex.sit
/
macc-carbon-demos-nonbinhex
/
chap25-demo-carbon events
/
ProgressIndicator.c
< prev
next >
Wrap
Text File
|
2001-05-18
|
2KB
|
86 lines
// *******************************************************************************************
// ProgressIndicator.c
// *******************************************************************************************
#include "Miscellany.h"
// …………………………………………………………………………………………………………………………………………………………………………………………………… global variables
extern WindowRef gWindowRef;
extern RGBColor gWhiteColour;
// ***************************************************************************** doProgressBar
void doProgressBar(void)
{
DialogRef dialogRef;
RgnHandle visRegionHdl = NewRgn();
ControlRef progressBarRef;
SInt16 statusMax, statusCurrent;
SInt16 a, b, c;
Handle soundHdl;
Rect portRect, theRect;
RGBColor redColour = { 0xFFFF, 0x0000, 0x0000 };
if(!(dialogRef = GetNewDialog(rDialog,NULL,(WindowRef) -1)))
ExitToShell();
SetPortDialogPort(dialogRef);
GetPortVisibleRegion(GetWindowPort(GetDialogWindow(dialogRef)),visRegionHdl);
UpdateControls(GetDialogWindow(dialogRef),visRegionHdl);
QDFlushPortBuffer(GetDialogPort(dialogRef),NULL);
SetPortWindowPort(gWindowRef);
GetWindowPortBounds(gWindowRef,&portRect);
GetDialogItemAsControl(dialogRef,iProgressIndicator,&progressBarRef);
statusMax = 3456;
statusCurrent = 0;
SetControlMaximum(progressBarRef,statusMax);
for(a=0;a<9;a++)
{
for(b=8;b<423;b+=18)
{
for(c=8;c<286;c+=18)
{
if(CheckEventQueueForUserCancel())
{
soundHdl = GetResource('snd ',rBarkSound);
SndPlay(NULL,(SndListHandle) soundHdl,false);
ReleaseResource(soundHdl);
DisposeDialog(dialogRef);
EraseRect(&portRect);
MoveTo(10,292);
RGBForeColor(&gWhiteColour);
DrawString("\pOperation cancelled at user request");
return;
}
SetRect(&theRect,b+a,c+a,b+17-a,c+17-a);
if(a < 3) RGBForeColor(&gWhiteColour);
else if(a > 2 && a < 6) RGBForeColor(&redColour);
else if(a > 5) RGBForeColor(&gWhiteColour);
FrameRect(&theRect);
QDFlushPortBuffer(GetWindowPort(gWindowRef),NULL);
QDFlushPortBuffer(GetDialogPort(dialogRef),NULL);
SetControlValue(progressBarRef,statusCurrent++);
}
}
}
DisposeRgn(visRegionHdl);
DisposeDialog(dialogRef);
EraseRect(&portRect);
MoveTo(10,292);
RGBForeColor(&gWhiteColour);
DrawString("\pOperation completed");
}
// *******************************************************************************************